﻿using LPLS.Commons.DBModule;
using LPLS.DBEntities;
using LPLS.DBEntities.LongGIModule;
using LPLS.DBInterface.LongGiMoudle;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LPLS.DBServices.LongGiMoudle
{
    public class LoulvDataService : DBBaseService, ILoulvDataService
    {
        public LoulvDataService(DBContext dbContext) : base(dbContext)
        {
        }

        public List<LoulvData> GetData(string GoongYi, string TubeName, DateTime stime, DateTime etime)
        {
            return this.Client.Queryable<LoulvData>().
              Where(e => e.TechnologyName == GoongYi && e.Time >= stime && e.Time <= etime && e.TubeName == TubeName)
              .ToList();
        }

        public List<string> GetGongyi()
        {
           var li= this.Client.Queryable<LoulvData>()
                .Select(e => e.TechnologyName)
                .Distinct()
                .ToList();
          
            return li;
        }

        public override void InitDataBaseName()
        {
            DataBaseName = DatabaseEnum.LongGiDB.ToString();
        }

        public int InsertData(LoulvData model)
        {
            return this.Client.Insertable(model).ExecuteCommand();
        }
    }
}
